package com.bilubi.reggie.reggie.mapper;

import com.bilubi.reggie.reggie.annotation.AutoFill;
import com.bilubi.reggie.reggie.bean.Setmeal;
import com.bilubi.reggie.reggie.bean.SetmealDish;
import com.bilubi.reggie.reggie.bean.vo.SetmealVo;
import com.bilubi.reggie.reggie.enums.OperateType;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface SetmealMapper {
    @AutoFill(value = OperateType.UPDATE)
    @CacheEvict(value = "Setmeal", allEntries = true)
    int deleteByPrimaryKey(List<Setmeal> setmeals);

    @CacheEvict(value = "Setmeal", allEntries = true)
    int insert(Setmeal record);

    @CacheEvict(value = "Setmeal", allEntries = true)
    @AutoFill(value = OperateType.INSERT)
    int insertSelective(SetmealVo record);

    Setmeal selectByPrimaryKey(Long id);

    @CacheEvict(value = "Setmeal", allEntries = true)
    @AutoFill(value = OperateType.UPDATE)
    int updateByPrimaryKeySelective(Setmeal record);

    @CacheEvict(value = "Setmeal", allEntries = true)
    int updateByPrimaryKey(Setmeal record);

    List<SetmealVo> selectAll(String name);

    int selectCountByCategoryId(Long id);

    SetmealVo selectSetmealVoWithDishesById(Long id);

    List<SetmealDish> selectDishesBySetmealId(Long id);

    @CacheEvict(value = "Setmeal", allEntries = true)
    @AutoFill(value = OperateType.UPDATE)
    Integer updateStatusById(List<Setmeal> setmeals);

    @Cacheable(value = "Setmeal", key = "'Setmeal_'+#categoryId")
    List<Setmeal> selectByCategoryId(Long categoryId);
}